package Try;

import java.util.Scanner;

public class Test4 {
    private static boolean NumberOfDigits(int n) {
        int num = n;
        int sum = 0;
        int count = 0;
        while (n > 0) {
            int tmp = (int) Math.pow(n % 10, 3);
            sum += tmp;
            n /= 10;
            count++;
        }
        return count == 3 && sum == num;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i <= n; i++) {
            if (NumberOfDigits(i)) {
                System.out.println(i+"是水仙花数");
            }
        }
    }
}
